<template>
  <view class="service-panel">
    <view class="service-panel__header">
      <text class="service-panel__title">{{ title }}</text>
      <view class="service-panel__action" v-if="showAction" @click="onActionClick">
        <text class="service-panel__action-text">{{ actionText }}</text>
        <text class="service-panel__action-icon">›</text>
      </view>
    </view>
    <view class="service-panel__content">
      <slot></slot>
    </view>
  </view>
</template>

<script setup>
import { defineProps, defineEmits } from 'vue';

const props = defineProps({
  title: {
    type: String,
    default: ''
  },
  showAction: {
    type: Boolean,
    default: false
  },
  actionText: {
    type: String,
    default: '查看全部'
  }
});

const emit = defineEmits(['action-click']);

const onActionClick = () => {
  console.log('点击了查看全部按钮');
  emit('action-click');
};
</script>

<style lang="scss" scoped>
.service-panel {
  background-color: #fff;
  margin-bottom: 10px;
  padding: 0 0 15px 0;
  
  &__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #f5f5f5;
  }
  
  &__title {
    font-size: 16px;
    font-weight: 500;
    color: #333;
  }
  
  &__action {
    display: flex;
    align-items: center;
    color: #07c160;
    font-size: 14px;
  }
  
  &__action-text {
    margin-right: 3px;
  }
  
  &__action-icon {
    font-size: 16px;
  }
  
  &__content {
    padding: 15px;
  }
}
</style>
